$(function(){
        $("#ruleSetOpt").change(function(){
           var ruleId=$(this).children('option:selected').val();
           if(ruleId=="0"){
             $("#cronSet").show();
           }else{
             $("#cronSet").hide();
           }
        });
      });
    
    
      //页面刷新
      function refreshJob(){
        $("form").attr("action","index.html").submit();
      }
      //任务重置
      function reSetJob(){
        $("form").attr("action","refreshJob.html").submit();
      }
      function deleteJob(jobName,jobGroup){
        $("input[name='jobName']").val(jobName);
        $("input[name='jobGroup']").val(jobGroup);
        $("form").attr("action","deleteJob.html").submit();
      }
      
      function reSetRuleModelShow(node){
        var tds=$(node).closest("tr").find("td");
        $("#tempGroup").text(tds.eq(1).text());
        $("#tempName").text(tds.eq(2).text());
        $("#tempDescription").text(tds.eq(2).find("span").attr("title"));
        $('#reSetRuleModal').attr("data-target",$(node).attr("id"));
        $('#reSetRuleModal').modal();
      }
      
      function submitControl(node,requestUrl){
        $("form>input[name='jobName']").val($(node).closest("tr").attr("data-jobName"));
        $("form>input[name='jobGroup']").val($(node).closest("tr").attr("data-jobGroup"));
        $("form>input[name='ruleType']").val($("#ruleSetOpt").children('option:selected').val());
        $("form>input[name='cronExpression']").val($("#reSetRuleModal #cronExpression").val());
        $("form>input[name='cronDescription']").val($("#reSetRuleModal #cronDescription").val());
        $("form").attr("action",requestUrl+".html").submit();
      }
      function reSetRule(){
        //验证数据
        var ruleType=$("#ruleSetOpt").children('option:selected').val();//规则
        var cronExpression=$("#cronExpression").val();
        var cronDescription=$("#cronDescription").val();
        var isPass=true;
        if(ruleType=="0"){
           if(cronExpression!=""){
             $("#cronExpression").closest(".form-group").addClass("has-success");
           }else{
             $("#cronExpression").attr("placeholder","此项必填").closest(".form-group").addClass("has-warning");
             isPass=false;
           }
           if(cronDescription!=""){
             $("#cronDescription").closest(".form-group").addClass("has-success");
           }else{
             $("#cronDescription").attr("placeholder","此项必填").closest(".form-group").addClass("has-warning");
              isPass=false;
           }
        }
        if(isPass){
            $('#reSetRuleModal').modal('hide');
	        submitControl($("#"+$('#reSetRuleModal').attr("data-target")),"reSetRule");
        }
      }